<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script src="./data.js"></script>

    <script>
      const { body } = res
      // console.log(body)
      const o = {}
      function getData(newObj, oldObj) {
        for (let key in oldObj) {
          if (
            Object.prototype.toString.call(oldObj[key]) === '[object Array]'
          ) {
            newObj[key] = []
            getData(newObj[key], oldObj[key])
          } else if (
            Object.prototype.toString.call(oldObj[key]) === '[object Object]'
          ) {
            newObj[key] = {}
            getData(newObj[key], oldObj[key])
          } else {
            if (key === 'label') {
              newObj.text = oldObj[key]
            }
          }
        }
      }
      getData(o, body)
      console.log(o)
    </script>
  </body>
</html>
